//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Web.UI;
using System.Web.UI.WebControls;

//NOTE: Original Author - Daniel Cazzulino
//Link: http://aspnet2.com/incubator/code/UnStyledCalendar.cs.txt

namespace CommunityServer.Controls
{
	/// <summary>
	/// The UnStyledCalendar control removes all of the style output by the default Calendar control.
	/// </summary>
	public class UnStyledCalendar : Calendar
	{
		/// <summary>
		/// Overrides the default HtmlTextWriter for a one which does not emit style attributes
		/// </summary>
		/// <param name="writer"></param>
		protected override void Render(HtmlTextWriter writer)
		{
			base.Render (new NonStyleWriter( writer) );
		}

		#region NonStyleWriter
		private class NonStyleWriter : HtmlTextWriter
		{
			HtmlTextWriter _writer;

			public NonStyleWriter(HtmlTextWriter innerWriter) : base(innerWriter.InnerWriter)
			{
				_writer = innerWriter;
			}

			#region Public members

			public override void AddAttribute(HtmlTextWriterAttribute key, string value)
			{
				_writer.AddAttribute(key, value);
			}
			public override void AddAttribute(HtmlTextWriterAttribute key, string value, bool fEncode)
			{
				_writer.AddAttribute(key, value, fEncode);
			}
			public override void AddAttribute(string name, string value)
			{
				_writer.AddAttribute(name, value);
			}
			public override void AddAttribute(string name, string value, bool fEndode)
			{
				_writer.AddAttribute(name, value, fEndode);
			}
			public override void AddStyleAttribute(HtmlTextWriterStyle key, string value)
			{
				// Do nothing here. We don't want style attributes!
			}
			public override void AddStyleAttribute(string name, string value)
			{
				// Do nothing here. We don't want style attributes!
			}
			public override void Close()
			{
				_writer.Close();
			}
			public override void Flush()
			{
				_writer.Flush();
			}
			public override void RenderBeginTag(HtmlTextWriterTag tagKey)
			{
				_writer.RenderBeginTag(tagKey);
			}
			public override void RenderBeginTag(string tagName)
			{
				_writer.RenderBeginTag(tagName);
			}
			public override void RenderEndTag()
			{
				_writer.RenderEndTag();
			}
			public override void Write(bool value)
			{
				_writer.Write(value);
			}
			public override void Write(char value)
			{
				_writer.Write(value);
			}
			public override void Write(char[] buffer)
			{
				_writer.Write(buffer);
			}
			public override void Write(char[] buffer, int index, int count)
			{
				_writer.Write(buffer, index, count);
			}
			public override void Write(double value)
			{
				_writer.Write(value);
			}
			public override void Write(int value)
			{
				_writer.Write(value);
			}
			public override void Write(long value)
			{
				_writer.Write(value);
			}
			public override void Write(object value)
			{
				_writer.Write(value);
			}
			public override void Write(float value)
			{
				_writer.Write(value);
			}
			public override void Write(string s)
			{
				_writer.Write(s);
			}
			public override void Write(string format, object arg0)
			{
				_writer.Write(format, arg0);
			}
			public override void Write(string format, object arg0, object arg1)
			{
				_writer.Write(format, arg0, arg1);
			}
			public override void Write(string format, params object[] arg)
			{
				_writer.Write(format, arg);
			}
			public override void WriteAttribute(string name, string value)
			{
				_writer.WriteAttribute(name, value);
			}
			public override void WriteAttribute(string name, string value, bool fEncode)
			{
				_writer.WriteAttribute(name, value, fEncode);
			}
			public override void WriteBeginTag(string tagName)
			{
				_writer.WriteBeginTag(tagName);
			}
			public override void WriteEndTag(string tagName)
			{
				_writer.WriteEndTag(tagName);
			}
			public override void WriteFullBeginTag(string tagName)
			{
				_writer.WriteFullBeginTag(tagName);
			}
			public override void WriteLine()
			{
				_writer.WriteLine();
			}
			public override void WriteLine(bool value)
			{
				_writer.WriteLine(value);
			}
			public override void WriteLine(char value)
			{
				_writer.WriteLine(value);
			}
			public override void WriteLine(char[] buffer)
			{
				_writer.WriteLine(buffer);
			}
			public override void WriteLine(char[] buffer, int index, int count)
			{
				_writer.WriteLine(buffer, index, count);
			}
			public override void WriteLine(double value)
			{
				_writer.WriteLine(value);
			}
			public override void WriteLine(int value)
			{
				_writer.WriteLine(value);
			}
			public override void WriteLine(long value)
			{
				_writer.WriteLine(value);
			}
			public override void WriteLine(object value)
			{
				_writer.WriteLine(value);
			}
			public override void WriteLine(float value)
			{
				_writer.WriteLine(value);
			}
			public override void WriteLine(string s)
			{
				_writer.WriteLine(s);
			}
			public override void WriteLine(string format, object arg0)
			{
				_writer.WriteLine(format, arg0);
			}
			public override void WriteLine(string format, object arg0, object arg1)
			{
				_writer.WriteLine(format, arg0, arg1);
			}
			public override void WriteLine(string format, params object[] arg)
			{
				_writer.WriteLine(format, arg);
			}
			public override void WriteLine(uint value)
			{
				_writer.WriteLine(value);
			}
			public override void WriteStyleAttribute(string name, string value)
			{
				// Do nothing here. We don't want style attributes!
			}
			public override void WriteStyleAttribute(string name, string value, bool fEncode)
			{
				// Do nothing here. We don't want style attributes!
			}
			public override System.Text.Encoding Encoding 
			{ 
				get { return _writer.Encoding; } 
			}
			public override string NewLine 
			{ 
				get { return _writer.NewLine; }
				set { _writer.NewLine = value; }
			}

			#endregion Public members
		}
		#endregion
	}

}
